package com.gsnd.gsnd21study.web;

import com.gsnd.gsnd21study.entity.DRO.RoleAndUser;
import com.gsnd.gsnd21study.entity.DRO.UserAndRole;
import com.gsnd.gsnd21study.entity.SysUser;
import com.gsnd.gsnd21study.service.SysRoleService;
import com.gsnd.gsnd21study.service.SysUserService;
import com.gsnd.gsnd21study.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class SysUserController {

    @Autowired
    SysUserService userService;

    @GetMapping("/ar/{userId}")
    public Result<UserAndRole> getUserAndRoleByUserId(@PathVariable Long userId){
        UserAndRole ur = userService.getUserAndRoleByUserId(userId);
        return Result.success(ur);
    }

    @GetMapping("/page")
    public Result<List<SysUser>> getUsersByPage(@RequestParam Integer pageNum,
                                                @RequestParam Integer pageSize){
        List<SysUser> list = userService.getUsersByPage(pageNum, pageSize);
        return Result.success(list);
    }
}
